WEBVTT

00:01.150 --> 00:06.250
In this video you will learn one of the most frequently used applications for moving averages and the

00:06.250 --> 00:09.690
finance and investment industry for decades.

00:09.700 --> 00:16.240
Financial traders and in particular traders who rely on technical analysis rather than fundamental analysis

00:16.570 --> 00:22.970
rely on so-called momentum strategies with a simple moving averages and you will see in a minute.

00:22.990 --> 00:25.020
The intuition behind the strategy.

00:25.300 --> 00:30.990
But first of all we still have imparted the S&amp;P 500 closed data.

00:31.000 --> 00:39.420
So let's have a look at the first five data points and the last five data points and let's create a

00:39.420 --> 00:47.250
brand new column called A simple moving average is 50 with um the simple moving average of the close

00:47.250 --> 00:50.040
price with a window of 50.

00:50.460 --> 00:56.520
So we're using the other rolling method on the S&amp;P 500 data frame with a window of 50.

00:56.520 --> 01:04.800
And we also need 50 periods to calculate the simple moving average and we change the mean method because

01:04.830 --> 01:08.180
we want to calculate moving averages.

01:08.340 --> 01:14.670
So let's do this here and let's have a look here at our data frame and we can see here that we have

01:14.760 --> 01:18.550
successfully added the column simple moving averages.

01:18.690 --> 01:25.090
50 and it's actually no surprise that for the first forty nine timestamps we have here any anywhere

01:25.130 --> 01:30.090
use because for these times stands we do not have 50 data points.

01:30.090 --> 01:34.140
So we have only nominal values in those columns starting from the 15th.

01:34.150 --> 01:38.190
The time stamp until the very last time stamp here.

01:38.190 --> 01:42.530
So here we can see the very last day of 2018.

01:42.630 --> 01:49.650
So here we have the price for the S&amp;P 500 and this is actually the simple moving average for the last

01:49.650 --> 01:57.740
the preceding 50 days and now we can also plot the S&amp;P 500 data frame with our two columns.

01:57.780 --> 02:02.450
So the actual close price and uh the simply moving average is 50.

02:02.880 --> 02:09.890
And of course you can do this here with the plot method so let's have a look here so we can see here

02:09.890 --> 02:13.670
in blue are the close price and in green.

02:13.700 --> 02:16.310
The simple moving average is 50.

02:16.910 --> 02:22.350
And we can see here that uh with uh moving averages the kind of smoothing.

02:22.370 --> 02:22.540
Yeah.

02:22.540 --> 02:23.330
Our data.

02:24.170 --> 02:31.010
So here at each and every timestamp we have actually the average for the preceding 50 timestamps.

02:31.070 --> 02:35.000
So therefore we have kind of a smooth and curve.

02:35.030 --> 02:41.000
So now let's move on and also create a column for the simple moving average 200.

02:41.030 --> 02:48.360
So here we have a rolling window of 200 timestamps and again we can do this year with the rolling method

02:48.390 --> 02:55.710
and past 200 to the windows perimeter and we want to calculate the simple moving average with the mean

02:55.710 --> 03:00.190
method so let's have a look here.

03:00.210 --> 03:06.870
Here we have the last five timestamps or for the simple moving average is two hundredths or the first

03:06.870 --> 03:12.870
one hundred ninety nine timestamps in our data frame that we have actually and a values party and the

03:12.870 --> 03:13.490
very end.

03:13.490 --> 03:15.710
Of course we have values.

03:15.780 --> 03:19.100
For the simple moving average 50 and 200.

03:19.200 --> 03:22.060
And let's also call you at the info method.

03:22.740 --> 03:29.010
And we can see here that in the close column we have two thousand five hundred sixty nine values and

03:29.010 --> 03:35.260
consequently for the SMI 50 year we have forty nine fewer data points and for the estimated two hundred

03:35.280 --> 03:38.910
we have one hundred and ninety nine fewer data points.

03:38.920 --> 03:41.770
And now let's also plot all the three columns here.

03:41.790 --> 03:43.790
So let's do this.

03:43.800 --> 03:50.070
So here we have uh the close column the S M A 50 and the ESA 200 column.

03:50.070 --> 03:56.460
And we can also see here that the S M A 50 is that's forty nine timestamps later and the S and may one

03:56.450 --> 03:59.370
hundred ninety nine timestamps later.

03:59.560 --> 04:01.790
And now let's only plot the estimate curve.

04:01.810 --> 04:06.960
So we're actually only plotting the last two columns here.

04:06.960 --> 04:11.310
So here we f and blue are the simple moving average is 50 and green.

04:11.310 --> 04:18.660
The simple moving average is 200 and it's no surprise that the estimate 200 is even more smooth than

04:18.690 --> 04:24.030
the SMI 50 and we could also say that the shorter term estimate.

04:24.030 --> 04:31.880
So the S and may 50 is actually reacting faster to price changes than the estimated 200.

04:31.920 --> 04:38.790
So for example here the blue line starts to decrease sharply and actually the Green Line takes some

04:38.790 --> 04:41.970
more time to actually also decrease.

04:41.970 --> 04:45.750
And this is actually the basis for a very simple trading strategy.

04:45.750 --> 04:49.860
So we have two simple moving averages with different windows.

04:49.860 --> 04:56.800
So we have one longer term window so you two hundred and one shorter term window 50.

04:57.030 --> 05:04.200
And the idea is that actually the trader invests when the shorter term S.M. A is above the longer term

05:04.230 --> 05:10.050
as an A and you should divest or even go short when the opposite holds true.

05:10.050 --> 05:15.710
So in this example here whenever the blue line is above uh the green line then we should invest into

05:15.720 --> 05:17.530
the S&amp;P 500.

05:17.670 --> 05:25.170
So it's here for example or here or in this period and whenever the blue line is uh below the green

05:25.170 --> 05:25.980
line.

05:25.980 --> 05:34.230
So for example here or here or here then we should divest from the S&amp;P 500 or even go short.

05:34.380 --> 05:41.370
And the rationale behind this is that the shorter assume a captures the most recent trends or the momentum

05:41.850 --> 05:46.710
and that the most recent trend will persist also in the near future.

05:47.370 --> 05:49.650
So for example let's have a look here.

05:49.680 --> 05:52.050
So here initially our blue line.

05:52.050 --> 06:00.240
So the s may 50 is below the green line and in this case we are not invested in the S&amp;P 500 or even

06:00.240 --> 06:02.640
we are short the S&amp;P 500.

06:02.820 --> 06:11.190
But then the S&amp;P 500 starts to increase and also the asset may 50 increase US uh faster than the S&amp;P

06:11.220 --> 06:12.660
200.

06:12.690 --> 06:17.130
So the most recent trend or the most recent momentum is positive.

06:17.280 --> 06:24.150
And therefore when both lines are crossing here and the blue line goes above the green line then we

06:24.150 --> 06:26.830
should invest in the S&amp;P 500.

06:27.030 --> 06:31.140
And this is in this case here for a very long time period.

06:31.560 --> 06:40.980
So we should invest here in the year 2012 and then we should divest into a 16 and then for a short term

06:40.980 --> 06:41.430
period.

06:41.430 --> 06:42.390
We are not investors.

06:42.450 --> 06:50.470
And then from to 16 to to 18 or to 19 we sought to again be invested in the S&amp;P 500.

06:50.520 --> 06:58.560
So this is the rationale behind this trading strategy and this is actually based on simple moving averages

06:58.740 --> 07:02.940
and the opposite of a momentum strategy would be a contrarian strategy.

07:03.030 --> 07:07.650
So we are finished with this video and I hope to see you also in the next one by.
